package com.yitao.cms.controller.shopInfo;

import com.skipper.base.bean.DataOutput;
import com.yitao.client.dto.shopInfo.HotSearchDto;
import com.yitao.cms.config.aopLog.LogAnnotation;
import com.yitao.cms.service.shopInfo.HotSearchCmsService;
import com.yitao.cms.utils.BaseUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(value = "/cms/hotSearch", produces = {"application/json"})
@Api(description = "运营后台-管理热门搜索", tags = {"cms-hotSearch"})
public class HotSearchCmsController {

	private BaseUtils baseUtils = BaseUtils.getInstance();

	@Autowired
	private HotSearchCmsService hotSearchCmsService;



	@ApiOperation("添加热搜索")
	@LogAnnotation(targetType = "hotSearchInfoSave", remark = "添加热搜索")
	@RequestMapping(value = "/saveHotSearchInfo", method = RequestMethod.POST)
	public DataOutput saveHotSearchInfo(HttpServletRequest request, @ApiParam(value = "热搜词", required = true) @RequestParam(value = "searchKey", required = true) String searchKey,
			@ApiParam(value = "id", required = false) @RequestParam(value = "id", required = false) Long id) {
		HotSearchDto dto = new HotSearchDto();
		dto.setSearchKey(searchKey);
		if(null != id){
			dto.setId(id);
		}
		return hotSearchCmsService.saveHotSearchInfo(request, dto);
	}

}
